package im.route.api.header;

import com.fasterxml.jackson.databind.annotation.JsonNaming;
import im.route.api.constants.SystemConstant;
import im.route.api.repository.RunningNumberRepositoryCustom;
import im.route.api.util.DateUtil;
import im.route.api.util.UpperSnakeCaseStrategy;
import org.apache.commons.lang3.StringUtils;
//import tech.kbtg.IntegrationModule.backoffice.repository.RunningNumberRepositoryCustom;
//import tech.kbtg.IntegrationModule.constants.SystemConstant;
//import tech.kbtg.IntegrationModule.util.DateUtil;
//import tech.kbtg.IntegrationModule.util.UpperSnakeCaseStrategy;

import java.io.Serializable;
import java.util.Date;

@JsonNaming(UpperSnakeCaseStrategy.class)
public class CupdHeaderRequest implements Serializable {
    private static final long serialVersionUID = 1641809085677676856L;

    private String versionId;
    private String serviceId;
    private String org;
    private String servicesn;
    private String channelId;
    private String acqId;
    private String subTerminalType;
    private String opId;
    private String requestTime;
    private String mac;
    private String transferFlag;

    public CupdHeaderRequest() {
        String now = DateUtil.convertToString(new Date(), null);
        this.org = "9972";
        this.channelId = "BANK";
        this.subTerminalType = "Web";
        this.versionId = "01";
        this.opId = null;
        this.requestTime = now;
        this.transferFlag = "N";
        this.servicesn = "APP" + now;
    }

    public String getVersionId() {
        return versionId;
    }

    public void setVersionId(String versionId) {
        this.versionId = versionId;
    }

    public String getServiceId() {
        return serviceId;
    }

    public void setServiceId(String serviceId) {
        this.serviceId = serviceId;
    }

    public String getOrg() {
        return org;
    }

    public void setOrg(String org) {
        this.org = org;
    }

    public String getServicesn() {
        return servicesn;
    }

    public void setServicesn(String servicesn) {
        this.servicesn = servicesn;
    }

    public String getChannelId() {
        return channelId;
    }

    public void setChannelId(String channelId) {
        this.channelId = channelId;
    }

    public String getSubTerminalType() {
        return subTerminalType;
    }

    public void setSubTerminalType(String subTerminalType) {
        this.subTerminalType = subTerminalType;
    }

    public String getOpId() {
        return opId;
    }

    public void setOpId(String opId) {
        this.opId = opId;
    }

    public String getRequestTime() {
        return requestTime;
    }

    public void setRequestTime(String requestTime) {
        this.requestTime = requestTime;
    }

    public String getMac() {
        return mac;
    }

    public void setMac(String mac) {
        this.mac = mac;
    }

    public String getAcqId() {
        return acqId;
    }

    public void setAcqId(String acqId) {
        this.acqId = acqId;
    }

    public String getTransferFlag() {
        return transferFlag;
    }

    public void setTransferFlag(String transferFlag) {
        this.transferFlag = transferFlag;
    }

    public void generateServiceSn(RunningNumberRepositoryCustom runningNumberRepository) {
        Long runningNo = runningNumberRepository.getRunningNumberByKey(SystemConstant.RUNNING_CUPD_HEADER);
        runningNo = runningNo % 100000;
        String runningNoTxt = StringUtils.leftPad(String.valueOf(runningNo), 5, "0");
        this.servicesn += runningNoTxt;
    }

    @Override
    public String toString() {
        return "CupdHeaderRequest{" +
                "versionId='" + versionId + '\'' +
                ", serviceId='" + serviceId + '\'' +
                ", org='" + org + '\'' +
                ", servicesn='" + servicesn + '\'' +
                ", channelId='" + channelId + '\'' +
                ", acqId='" + acqId + '\'' +
                ", subTerminalType='" + subTerminalType + '\'' +
                ", opId='" + opId + '\'' +
                ", requestTime='" + requestTime + '\'' +
                ", mac='" + mac + '\'' +
                ", transferFlag='" + transferFlag + '\'' +
                '}';
    }
}
